//
//  MBChatPreviewVideoViewController.m
//  Meboo
//
//  Created by kyo on 2023/10/21.
//

#import "MBChatPreviewVideoViewController.h"
#import "MBChatPreviewVideoView.h"
@interface MBChatPreviewVideoViewController ()
@property (nonatomic, strong) MBChatPreviewVideoView *playerView;
@property (nonatomic, strong) UIButton *backBtn;
@end

@implementation MBChatPreviewVideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HEXS(@"22253C");
    [self setupUI];
}

#pragma mark - Action
- (void)backAction {
    [self dismissViewControllerAnimated:YES completion:nil];;
}

#pragma mark - UI
- (void)setupUI {
    CGFloat maxHeight = ScreenHeight-TabbarSafeBottomMargin-MBHeightScale(89)-MBHeightScale(34)-StatusBarAndNavigationBarHeight;
    
    [self.view addSubview:self.playerView];
    [self.playerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.mas_equalTo(MBHeightScale(34)+StatusBarAndNavigationBarHeight);
        make.height.mas_equalTo(maxHeight);
    }];
    
    [self.view addSubview:self.backBtn];
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(MBWidthScale(20));
        make.top.mas_equalTo(StatusBarAndNavigationBarHeight-MBHeightScale(35));
        make.width.height.mas_equalTo(MBHeightScale(30));
    }];
}

#pragma mark - Setter && Getter
- (MBChatPreviewVideoView *)playerView {
    if (!_playerView) {
        _playerView = [[MBChatPreviewVideoView alloc] initWithUrl:self.videoUrl];
    }
    return _playerView;
}

- (UIButton *)backBtn {
    if (!_backBtn) {
        _backBtn = [[UIButton alloc] init];
        _backBtn.layer.cornerRadius = MBHeightScale(30/2);
        [_backBtn setImage:ImageWithName(@"chat_back") forState:0];
        [_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backBtn;
}

@end
